package com.ruoyi.sl.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.sl.domain.SlOfcbase;
import com.ruoyi.sl.service.ISlOfcbaseService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 行政绩效系数Controller
 * 
 * @author admin
 * @date 2024-06-03
 */
@RestController
@RequestMapping("/sl/ofcbase")
public class SlOfcbaseController extends BaseController
{
    @Autowired
    private ISlOfcbaseService slOfcbaseService;

    /**
     * 查询行政绩效系数列表
     */
    @PreAuthorize("@ss.hasPermi('sl:ofcbase:list')")
    @GetMapping("/list")
    public TableDataInfo list(SlOfcbase slOfcbase)
    {
        startPage();
        List<SlOfcbase> list = slOfcbaseService.selectSlOfcbaseList(slOfcbase);
        return getDataTable(list);
    }

    /**
     * 导出行政绩效系数列表
     */
    @PreAuthorize("@ss.hasPermi('sl:ofcbase:export')")
    @Log(title = "行政绩效系数", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SlOfcbase slOfcbase)
    {
        List<SlOfcbase> list = slOfcbaseService.selectSlOfcbaseList(slOfcbase);
        ExcelUtil<SlOfcbase> util = new ExcelUtil<SlOfcbase>(SlOfcbase.class);
        util.exportExcel(response, list, "行政绩效系数数据");
    }

    /**
     * 获取行政绩效系数详细信息
     */
    @PreAuthorize("@ss.hasPermi('sl:ofcbase:query')")
    @GetMapping(value = "/{ofcbaseId}")
    public AjaxResult getInfo(@PathVariable("ofcbaseId") Long ofcbaseId)
    {
        return success(slOfcbaseService.selectSlOfcbaseByOfcbaseId(ofcbaseId));
    }

    /**
     * 新增行政绩效系数
     */
    @PreAuthorize("@ss.hasPermi('sl:ofcbase:add')")
    @Log(title = "行政绩效系数", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SlOfcbase slOfcbase)
    {
        slOfcbase.setCreateBy(getUsername());
        return toAjax(slOfcbaseService.insertSlOfcbase(slOfcbase));
    }

    /**
     * 修改行政绩效系数
     */
    @PreAuthorize("@ss.hasPermi('sl:ofcbase:edit')")
    @Log(title = "行政绩效系数", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SlOfcbase slOfcbase)
    {
        slOfcbase.setUpdateBy(getUsername());
        return toAjax(slOfcbaseService.updateSlOfcbase(slOfcbase));
    }

    /**
     * 删除行政绩效系数
     */
    @PreAuthorize("@ss.hasPermi('sl:ofcbase:remove')")
    @Log(title = "行政绩效系数", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ofcbaseIds}")
    public AjaxResult remove(@PathVariable Long[] ofcbaseIds)
    {
        return toAjax(slOfcbaseService.deleteSlOfcbaseByOfcbaseIds(ofcbaseIds));
    }
}
